1
2
3
4
5
6
7 package uk.ac.roe.antigen.dialogs;
8
9 import java.awt.event.ActionEvent;
10 import java.awt.event.ActionListener;
11 import java.io.File;
12
13 import javax.swing.JFileChooser;
14 import javax.swing.JFrame;
15
16 /***
17 * @author jdt
18 *
19 * @todo To change the template for this generated type comment go to
20 * Window - Preferences - Java - Code Style - Code Templates
21 */
22 public class DirPropertyInputHandler extends AbstractFilePropertyInputHandler {
23
24 /***
25 * @param frame
26 */
27 public DirPropertyInputHandler(JFrame frame) {
28 super(frame);
29 }
30
31 /***
32 * Auto-generated main method to display this JDialog
33 */
34 public static void main(String[] args) {
35 JFrame frame = new JFrame();
36 frame.show();
37 AbstractFilePropertyInputHandler inst = new DirPropertyInputHandler(frame);
38 inst.setVisible(true);
39 }
40
41 /***
42 * @return
43 */
44 protected ActionListener getBrowseButtonListener() {
45 return new ActionListener() {
46 public void actionPerformed(ActionEvent evt) {
47 JFileChooser chooser = new JFileChooser();
48 chooser.setApproveButtonText("Select");
49 chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
50 String currentValue = propertyValueTxt.getText();
51 chooser.setSelectedFile(new File(currentValue));
52 int returnVal = chooser.showOpenDialog(DirPropertyInputHandler.this);
53 if(returnVal == JFileChooser.APPROVE_OPTION) {
54 propertyValueTxt.setText(chooser.getSelectedFile().toString());
55 }
56 }
57 };
58 }
59 }